from ChatGLM_new import zhipu_llm
from ChatGLM import ChatGLM_LLM
from langchain_core.messages import AIMessage, HumanMessage, SystemMessage
from transformers import pipeline
import time
from langchain.prompts import PromptTemplate
from langchain.chains import ConversationChain
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler

llm = zhipu_llm 
llm.temperature=0.1
conversation = ConversationChain(llm=llm)
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
prompt = ChatPromptTemplate.from_template("{topic}")
parser = StrOutputParser()
chain = prompt | conversation | parser
# print(chain.invoke({"topic": "红楼梦讲了什么"}))

print(conversation.invoke("红楼梦讲了什么"))
print(conversation.invoke("最近有什么好看的电影"))
conversation.memory.clear()
print(conversation.invoke("顺德有什么美食"))
print(conversation.invoke("我们刚才聊了什么"))


